package com.suitsoft.ut.service.base;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.suitsoft.ut.commons.Constants;
import com.suitsoft.ut.commons.UserHolder;
import com.suitsoft.ut.dao.base.CollegeDao;
import com.suitsoft.ut.entity.base.College;

/**
 * 学院管理  服务层类
 *@author Suineg
 */
@Service
@Transactional
public class CollegeManager {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private CollegeDao collegeDao;

	public College get(Long id){
		return collegeDao.get(id);
	}
	
	public List<College> getByUser(){
		String idss = UserHolder.getLoginUser().getCollegeCode();
		List<Long> ids = Constants.getListIdsByCollegeId(idss);
		return collegeDao.get(ids);
	}
	
	public void save(College college){
		collegeDao.save(college);
	}
	
	public List<College> getAll(){
		return collegeDao.getAll();
	}
	
	public List<College> findByName(String collegeName){
		return collegeDao.findBy("collegeName", collegeName);
	}
	
	public Page<College> findLikeByName(List<PropertyFilter> filters,Page<College> page){
		return collegeDao.findPage(page,filters);
	}
}

